// echo_client.cpp: test for ClientSocket
#include "ClientSocket.h"
#include "SocketException.h"
#include <iostream>
#include <string>
using namespace std;

int main ( int argc, char* argv[] )
{
    string server = "localhost";
    try
    {
        // 1.create socket,connect to server
        ClientSocket client_socket ( server, 30000 );
        
        // 2.send message to server
        string request("hello,who're you?");
        client_socket<<request;
        cout<<"client:"<<request<<endl;

        // 3.receive from server
        string reply;
        client_socket>>reply;
        cout<<"server:"<<reply<<endl;
    }
    catch ( SocketException& ex)
    {
        cout << ex.description() << endl;
    }
}

